{extend name="public/base"/}
{block name="style"}

{/block}
{block name="body"}
	<header class="ui-header">  
	    <div class="ui-icon-left">
	        <a href="javascript:history.back(-1)" class="ui-icon-text btn-cancel">取消</a>
	    </div>
	    <h1 class="ui-title">评论</h1>
	    <div class="ui-icon-right">
	        <a href="javascript:;" class="ui-icon-text btn-publish">发表</a>
	    </div>
	    <!--导航-->
	    {block name="include"}{include file="public:dropnav" /}{/block}
	</header>
	<div class="weui-content">
		<div class="form-textarea">
			<textarea name="content" id="content" placeholder="期待您对《{$articlename}》的评论"></textarea>
		</div>
	</div>
	 <!--加入书架成功提示-->
    <div id="toast" style="display: none;">
        <div class="weui-mask_transparent"></div>
        <div class="weui-toast">
            <i class="weui-icon-success-no-circle weui-icon_toast"></i>
            <p class="weui-toast__content">操作成功</p>
        </div>
    </div>
	<!--加入书架错误提示-->
    <div id="toasterror" style="display: none;">
        <div class="weui-mask_transparent"></div>
        <div class="weui-toast">
            <i class="weui-icon-info-circle weui-icon_toast"></i>
            <p class="weui-toast__content">未登录</p>
        </div>
    </div>
{/block}
{block name="script"}
	<script src="__PUBLIC__/novel/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="__PUBLIC__/novel/js/common.js" type="text/javascript" charset="utf-8"></script>
    <script src="__PUBLIC__/novel/js/weui.min.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		$(function(){
			var $toast = $('#toast');
			var $toasterror = $('#toasterror');
			$('.btn-publish').on('click',function(){
				var content = $('#content').val();
				var articleid = {$bookid};
				$.ajax({
	                type: 'POST',
	                url:'/book/commit',
	                dataType: 'json',
					data : {'articleid':articleid,'content':content},
	                success: function(json){
	                	if(json.code==1){
							$toast.fadeIn(100);
							setTimeout(function () {
								$toast.fadeOut(100);
								window.location.href = "/book/info/id/"+articleid+".html";
							}, 2000);
						}else{
							$toasterror.fadeIn(100);
							setTimeout(function () {
								$toasterror.fadeOut(100);
							}, 2000);
						}
	                },
	                error: function(xhr, type){
	                    $toasterror.fadeIn(100);
							setTimeout(function () {
								$toasterror.fadeOut(100);
						}, 2000);
	                }
	            });
			});
		});
	</script>
{/block}